from Crypto.Cipher import AES
import base64

def pkcs5_pad(data):
    pad_length = 16 - len(data) % 16
    return data + bytes([pad_length] * pad_length)

def a(str_key, str2):
    key_bytes = str_key.encode()[:16]
    key_bytes = key_bytes.ljust(16, b'\x00')  # Java 如果不足16字节补0
    data = pkcs5_pad(str2.encode())
    cipher = AES.new(key_bytes, AES.MODE_ECB)
    encrypted = cipher.encrypt(data)
    return base64.b64encode(encrypted).decode()

# 测试参数
str_key = "amJKJsirodlsd129"
str2 = '''{"bd_return_size":"71.5791","bd_net_type":"wifi","bd_return_time":"0.358","bd_dtime":"1754536861","list":[{"local_ip":"","url":"https://iphone.myzaker.com/zaker/interaction.php?_appid\\u003dAndroidPhone\\u0026_brand\\u003dRedmi\\u0026_clicode\\u003ddrkjeSEfcYDX1teOXihrCj2XzcFRNfVX8%2BYz4c8F97ou09PFuxwXRz5MiGDDPUNGhem0wpj6%2FrZjDz2db1S7FvanFsXVXzuSqDN0%2F9H5fXQboq5tdRLZNTtTWglt14Ow2up6UUUAOroimS1HlUPRnt%2FCQ4I%2BuQaYbMO3tBgfzppDreyPYJ3gJetESX4Iz9g%2F\\u0026_dev\\u003d39\\u0026_mcode\\u003d782ECE9C\\u0026_only_read\\u003dN\\u0026_os\\u003d13_23013RK75C\\u0026_os_name\\u003d23013RK75C\\u0026_udid\\u003d1fb67af59b5699a6\\u0026_v\\u003d9.1.5\\u0026_version\\u003d9.08\\u0026appType\\u003dnormal","net_type":"wifi","req_type":"local","e_type":"2","return_time":"3.23","dtime":"1.75453683E9"},{"local_ip":"","url":"https://iphone.myzaker.com/zaker/app_style.php?_appid\\u003dAndroidPhone\\u0026_brand\\u003dRedmi\\u0026_clicode\\u003ddrkjeSEfcYDX1teOXihrCj2XzcFRNfVX8%2BYz4c8F97ou09PFuxwXRz5MiGDDPUNGhem0wpj6%2FrZjDz2db1S7FvanFsXVXzuSqDN0%2F9H5fXQboq5tdRLZNTtTWglt14Ow2up6UUUAOroimS1HlUPRnt%2FCQ4I%2BuQaYbMO3tBgfzppDreyPYJ3gJetESX4Iz9g%2F\\u0026_dev\\u003d39\\u0026_flag\\u003d9f0369ff51876206a9b5dd33b6d91686\\u0026_mcode\\u003d782ECE9C\\u0026_only_read\\u003dN\\u0026_os\\u003d13_23013RK75C\\u0026_os_name\\u003d23013RK75C\\u0026_time\\u003d1754536856\\u0026_udid\\u003d1fb67af59b5699a6\\u0026_v\\u003d9.1.5\\u0026_version\\u003d9.08\\u0026appType\\u003dnormal\\u0026sign_arg\\u003dapp_style|_appid,_nudid,_udid,_uid,_version","net_type":"wifi","req_type":"local","e_type":"2","return_time":"3.26","dtime":"1.75453683E9"},{"local_ip":"","url":"https://iphone.myzaker.com/zaker/ar_data/ar_list.php?_appid\\u003dAndroidPhone\\u0026_brand\\u003dRedmi\\u0026_clicode\\u003ddrkjeSEfcYDX1teOXihrCj2XzcFRNfVX8%2BYz4c8F97ou09PFuxwXRz5MiGDDPUNGhem0wpj6%2FrZjDz2db1S7FvanFsXVXzuSqDN0%2F9H5fXQboq5tdRLZNTtTWglt14Ow2up6UUUAOroimS1HlUPRnt%2FCQ4I%2BuQaYbMO3tBgfzppDreyPYJ3gJetESX4Iz9g%2F\\u0026_dev\\u003d39\\u0026_mcode\\u003d782ECE9C\\u0026_only_read\\u003dN\\u0026_os\\u003d13_23013RK75C\\u0026_os_name\\u003d23013RK75C\\u0026_udid\\u003d1fb67af59b5699a6\\u0026_v\\u003d9.1.5\\u0026_version\\u003d9.08\\u0026appType\\u003dnormal","net_type":"wifi","req_type":"local","e_type":"2","return_time":"3.363","dtime":"1.75453683E9"}]}'''

print(a(str_key, str2))